package cn.edu360.day07;

import cn.edu360.day07.utile.Utiles;

import java.io.*;

/**
 * develop测试
 * Created by root on 2018/7/9.
 * master上的开发
 */
public class Reportery {
    public static void main(String[] args) {
        //乱码解决
        try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("d:\\\\data\\\\bj-poi-1.csv"),"gbk"));
             BufferedWriter bw = new BufferedWriter(new FileWriter("d:\\data\\reportery.txt"));
        ) {
            //跳过第一行
            br.readLine();
            String line = null;
            while((line=br.readLine())!=null){
                try{
                    //System.out.println(line);   经纬度   地址（省，市，区，具体的地址）
                    String[] split = line.split(",");
                    String addr = split[0];
                    double lng = Double.parseDouble(split[2]);
                    double lat = Double.parseDouble(split[3]);
                    String province = split[5];
                    String district = split[7];
                    //经纬度转换
                    String hashCode = Utiles.getGeoHashCode(lng, lat);

                    //写到文件中
                    String ret = hashCode+","+province+","+province+","+district+","+addr;
                    bw.write(ret);
                    bw.newLine();
                }catch (Exception e){
                    continue;
                }

            }
            bw.flush();
        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
